use dbTrain
go

--CATEGORY
--Store Procedure Addnew Category

create procedure spAddNewCategory
	@CategoryName nvarchar(50)
as
	begin
		insert into Category(CategoryName) values(@CategoryName)
	end
go
--Store Procedure Update Category

create procedure spUpdateCategory
	@CategoryID int,
	@CategoryName nvarchar(50)
as
	begin
		Update Category set CategoryName = @CategoryName where CategoryID = @CategoryID
	end
go
--Store Procedure Delete Category

create procedure spDeleteCategory
	@CategoryID int
as
	begin
		Delete Category where CategoryID = @CategoryID
	end
go

--TRAINTYPE
--Store Procedure Addnew TrainType

create procedure spAddNewTrainType
	@Type nvarchar(50)
as
	begin
		insert into TrainType(Type) values(@Type)
	end
go
--Store Procedure Update TrainType

create procedure spUpdateTrainType
	@TrainTypeID int,
	@Type nvarchar(50)
as
	begin
		Update TrainType set [Type] = @Type where TrainTypeID = @TrainTypeID
	end
go
--Store Procedure Delete TrainType

create procedure spDeleteTrainType
	@TrainTypeID int
as
	begin
		Delete TrainType where TrainTypeID = @TrainTypeID
	end
go

--TRAIN
--Store Procedure Addnew Train

create procedure spAddNewTrain
	@TrainName nvarchar(50),
	@CategoryID int,
	@Seat int,
	@TrainTypeID int
as
	begin
		insert into Train(TrainName, CategoryID, Seat, TrainTypeID) values(@TrainName, @CategoryID, @Seat, @TrainTypeID)
	end
go
--Store Procedre Update Train

create procedure spUpdateTrain
	@TrainID int,
	@TrainName nvarchar(50),
	@CategoryID int,
	@Seat int,
	@TrainTypeID int
as
	begin
		Update Train set TrainName = @TrainName, CategoryID = @CategoryID, Seat = @Seat, TrainTypeID = @TrainTypeID where TrainID = @TrainID
	end
go
--Store Procedure Delete TrainType

create procedure spDeleteTrain
	@TrainID int
as
	begin
		Delete Train where TrainID = @TrainID
	end
go

--PLACE
--Store Procedure Addnew Place

create procedure spAddNewPlace
	@PlaceName nvarchar(50)
as
	begin
		insert into Place(PlaceName) values(@PlaceName)
	end
go
--Store Procedure Update Place

create procedure spUpdatePlace
	@PlaceID int,
	@PlaceName nvarchar(50)
as
	begin
		Update Place set PlaceName = @PlaceName where PlaceID = @PlaceID
	end
go
--Store Procedure Delete Place

create procedure spDeletePlace
	@PlaceID int
as
	begin
		Delete Place where PlaceID = @PlaceID
	end
go
--Store Procedure GetAll Category
create procedure spGetAllCategory
as
	begin
		Select * from Category
	end
go
--Store Procedure GetAll Place
create procedure spGetAllPlace
as
	begin
		Select * from Place
	end
go
--Store Procedure GetAll Train Type
create procedure spGetAllTraintype
as
	begin
		Select * from TrainType
	end
go
--Store Procedure GetAll Category
create procedure spGetAllTrain
as
	begin
		Select * from Train
	end
go